<?php
	require_once('../config.php');
	include_once(ROOT_DIR."/database/DataBase.php");
	include_once(ROOT_DIR."/include/function.php");
				
	session_start();
	checkLogin();

	$cid = $_SESSION["company_id"];
	$date_from = $_POST["date_from"];
	$date_to = $_POST["date_to"];
	
	$database = New DataBase();
	$database->open_connection();
	$resultSet = $database->getDataByDate($date_from, $date_to, $cid);
	
	
?>

<html>
	<head>
		<title>CMS - Item</title>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
		<?php
			include_once(ROOT_DIR."/include/includeHeader.php");
		?>
		<link rel="Stylesheet" type="text/css" href="<?echo $config["root"];?>/css/jHtmlArea.css" />
		<script type="text/javascript" src="<?echo $config["root"];?>/js/jHtmlArea"></script>
		<script type="text/javascript">
			$(function() {
				$( "#date_from" ).datepicker({
					dateFormat: 'dd/mm/yy',
					changeMonth: true,
					changeYear: true
				});
				$( "#date_to" ).datepicker({
					dateFormat: 'dd/mm/yy',
					changeMonth: true,
					changeYear: true
				});
			});
		
		</script>
	</head>
	<body>
		<?php
			include_once(ROOT_DIR."/include/top_navigation.php");
		?>
		<div Class="Middle">
			<div class="LeftMenu">
				<?php include_once(ROOT_DIR."/include/left_menu.php"); ?>
			</div>
			<div id="RightContent" >
				<form name="new_product" method="POST" action="../include/product_add_process.php" enctype="multipart/form-data">
				<table>
					<tr>
						<td>Search Date : </td>
						<td>From : <input type="text" name="date_from" class="date_from" id="date_from" value="" /> To : <input type="text" name="date_to" class="date_to" id="date_to" value="" /></td>
					</tr>
					<tr>
						<td colspan="2"><input type="button" name="button" value="Submit" onclick="javascript: checkSubmit();"/></td>
					</tr>
					<tr>
						<td>
							<?
								$i=0;
								while ($row = mysql_fetch_assoc($resultSet)) {
									$data[$i] = array($row["pid"], $row["p_sum"]);
									$i++;
								}
								
								
								
								$serialized_ar = json_encode($data);
								
								echo $serialized_ar;
								
							?>
							<img src="../contrib/graphicBarChat.php?data=<? echo $serialized_ar;?>&title=waaaagh" />
						</td>
					</tr>
				</table>
				<input type="hidden" name="cid" id="cid" value="<? echo $cid;?>" />
				</form>
			</div>
		</div>
		
		
		
		<?php
			include_once(ROOT_DIR."/include/footer.php");
		?>
	</body>
</html>
<?
	//mysql_free_result($status);
	//mysql_free_result($category);
	$database->close_connection();
?>